
library(testthat)
library(blma)
library(tictoc)
library(parallel)

cores <- detectCores()

test_that('comCrime produces correct results ZE', {
	set.seed(2019)
    comCrime <- get_comCrime()
    vy <- comCrime$vy
    mX <- comCrime$mX
    tic('comCrime produces correct results ZE')
    result <- sampler(100000, vy, mX, prior='ZE', modelprior='uniform', cores=cores)
    toc()
    expect_equal(result$vinclusion_prob, 
				 c(
0.94652000000000003,0.76881999999999995,0.21004000000000000,
0.80601999999999996,0.18861000000000000,0.61153999999999997,
0.15892999999999999,0.31552999999999998,0.18381000000000000,
0.46372000000000002,0.28755999999999998,0.24101000000000000,
0.16950999999999999,0.22846000000000000,0.09386000000000000,
0.11037000000000000,0.19811000000000001,0.16356999999999999,
0.23360000000000000,0.13303999999999999,0.21229999999999999,
0.19106000000000001,0.23682000000000000,0.17039000000000001,
0.15121999999999999,0.11920000000000000,0.19186000000000000,
0.13411000000000001,0.31228000000000000,0.14785000000000001,
0.38558999999999999,0.12872000000000000,0.13353000000000001,
0.13897999999999999,0.20521000000000000,0.13178000000000001,
0.14008999999999999,0.14468000000000000,0.13225000000000001,
0.79439000000000004,0.26307999999999998,0.17544999999999999,
0.33228000000000002,0.63861000000000001,0.18845999999999999,
0.36093999999999998,0.11133000000000000,0.11153000000000000,
0.88029000000000002,0.96462999999999999,0.96448999999999996,
0.11654000000000000,0.16206999999999999,0.22911000000000001,
0.61292000000000002,0.12328000000000000,0.17072999999999999,
0.14380999999999999,0.14602000000000001,0.32174999999999998,
0.13525999999999999,0.31498999999999999,0.23190000000000000,
0.23524999999999999,0.23554000000000000,0.32361000000000001,
0.20899999999999999,0.54813000000000001,0.14784000000000000,
0.09420000000000001,0.93078000000000005,0.20771999999999999,
0.19017000000000001,0.10370000000000000,0.19575999999999999,
0.11193000000000000,0.14513000000000001,0.28532000000000002,
0.33246999999999999,0.24446999999999999,0.27033000000000001,
0.11441999999999999,0.13206000000000001,0.29209000000000002,
0.18156000000000000,0.10234000000000000,0.65824000000000005,
0.13550000000000001,0.32285999999999998,0.56325000000000003,
0.11633000000000000,0.12889000000000000,0.78490000000000004,
0.15919000000000000,0.14621000000000001,0.10469000000000001,
0.09723999999999999,0.09600000000000000,0.91712000000000005
)
, tolerance = 1e-5)
})